/*****
 * DataEditActivity
 * ����ǰ׺��׺
 * ******/
package com.scanner.hardware;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class DataEditActivity extends Activity implements OnClickListener{

	private Button setPrefix,setSuffix;
	private EditText contentPrefix,contentSuffix;
	private SharedPreferences mSharedPreferences;
	private Editor editor;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.data_edit);
		initViews();
		
		//mSharedPreferences = getSharedPreferences("config", Context.MODE_PRIVATE);
		mSharedPreferences = getSharedPreferences("com.android.barcodescanner_preferences", Context.MODE_PRIVATE);
		editor = mSharedPreferences.edit();
	}
	
	private void initViews(){
		setPrefix = (Button)findViewById(R.id.prefix_set);
		setSuffix = (Button)findViewById(R.id.suffix_set);
		setPrefix.setOnClickListener(this);
		setSuffix.setOnClickListener(this);
		
		contentPrefix = (EditText)findViewById(R.id.prefix_content);
		contentSuffix = (EditText)findViewById(R.id.suffix_content);
	}
	@Override
	public void onClick(View v) {
		switch(v.getId()){
		case R.id.prefix_set:
			editor.putString("prefix", contentPrefix.getText().toString());
			editor.commit();
			contentPrefix.setText("");
			Toast.makeText(this, "set prefix successful", Toast.LENGTH_LONG).show();
			break;
		case R.id.suffix_set:
			editor.putString("suffix", contentSuffix.getText().toString());
			editor.commit();
			contentSuffix.setText("");
			
			Toast.makeText(this, "set suffix successful", Toast.LENGTH_LONG).show();
			break;
		default:
				break;
		}
		
	}

	
}
